<template>
  <div>
    <div>孙组件{{num}}</div>
    <button @click='handleClick'>点击</button>
  </div>
</template>
<script>
import { inject } from 'vue'

export default {
  name: 'GrandSon',
  setup () {
    const num = inject('num')
    // getNum是函数
    const getNum = inject('get-num')

    const handleClick = () => {
      // 调用爷爷组件传递过来的回调函数
      getNum(500)
    }
    return { num, handleClick }
  }
}
</script>
